home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 52
/
Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso
/
Aminet
/
misc
/
emu
/
Apex-src.lha
/
ASM.DOC
< prev
next >
Wrap
Text File
|
2001-09-30
|
11KB
|
328 lines
ASM.DOC AUG-21-86
USING THE 68000 ASSEMBLER
This document describes the operation of the 68000 assembler; it does
not describe the 68000 instruction set. It is assumed that you are
already familiar with programming in assembly language.
SYNTAX
A line of assembly code can have one or more of the following fields.
Fields are separated by tabs or spaces.
LABEL OPCODE OPERAND ;COMMENT
If a label is used, it must start in the first column. Label names must
start with a letter (A-Z or a-z) and can consist of letters, numbers
(0-9), or underlines (_). The assembler makes no distinction between
uppercase and lowercase letters (except in strings). Names can be as
long as you want, but only the first eight characters are recognized.
The opcode field begins anywhere after the first column, to distinguish
it from a label. An opcode may be either a 68000 instruction name or
one of the pseudo-ops described later on.
An operand is typically an effective address for a 68000 instruction.
An operand can be a simple label name or it can be a complex
expression. An operand must always be preceded by an opcode.
The last field on the line is the comment field. You can use any
characters here, but they must be preceded by a semicolon (;). Since
any of the fields may be blank, a comment might be used as the only
field on the line. Comments can start anywhere, even in the first
column. Blank lines are treated as comments.
An expression is evaluated the same way as in XPL except that brackets
"[]" are used instead of parentheses "()" (parentheses are reserved for
indexing). Space characters can be used within expressions to make them
more readable. All numeric values are signed, 32-bit integers in the
range -2,147,483,648 through +2,147,483,647.
The order in which an expression is evaluated can affect its value. The
assembler performs the operations with the highest precedence first. If
operators have the same precedence then the order of evaluation is from
left to right. Expressions within brackets are always evaluated first.
PRECEDENCE OPERATOR
1 [ ]
2 unary + -
3 * / \
4 + -
5 = # > < >= <=
6 ~
7 &
8 !
A precise definition of the syntax is given by the syntax diagrams.
PSEUDO-OPS
In addition to the 68000 opcodes, there are pseudo opcodes (pseudo-ops)
which are commands to the assembler.
ORG EXPRESSION Sets the program counter to the value of
the expression. If a label is used, it
will have the value of the expression.
LABEL EQU EXPRESSION Sets the label to the value of the
expression. A label defined by EQU
cannot be redefined. (Forward references
are allowed, but they are risky.)
NOLIST Turns off the listing device.
LIST Turns on the listing device.
PAGE Sends a form feed to the listing device,
which moves it to the top of the next
page.
DC._ EXPRESSION Defines a constant value to be loaded
into the current memory location. A
size must be specified: .B, .W, or .L.
Multiple values can be specified by
additional expressions separated by
commas.
DS._ EXPRESSION Defines storage space. The amount of
space is equal to the value of the
expression times the number of bytes
in the size specification. The loader
(LOAD) does not affect these locations.
DCB._ TIMES,VALUE Defines a block of constants. VALUE is
an expression giving the value of the
constant. TIMES is the number of times
the constant value is repeated.
ASCII "STRING" Defines a block of constant bytes equal
to the ASCII values of the string
enclosed in quote marks. Bit 7 is always
clear. If the string contains a double
quote (") then enclose the string in
single quotes ('). If the string con-
tains an apostrophe (') then enclose the
string in double quotes. If the closing
quote mark is omitted then a carriage
return will be included in the string.
IF EXPRESSION Turns off the assembler under certain
conditions. If the expression evaluates
to false (= 0) then the lines of assem-
bly code up to ELSE or ENDIF are treated
as comments.
ELSE Reverses the condition of a preceding IF.
ENDIF Turns on the assembler.
INCLUDE 3:FILENAME.68K Inserts code from another file. The unit
and extension can be specified, but they
default to the input unit and ".68K". A
label name cannot be used for the unit.
END Indicates the end of the program.
ASSEMBLING A PROGRAM
After a program has been created, it can be assembled by typing the
command:
APX>ASM file name
Where "file name" is the name of your program. (Note that a space
character is sufficient if the default file name is set up.)
The assembler begins by asking if you want to change the defaults.
Unless you want a listing, enter "N" (or just RETURN). Your program
will be assembled. If an error is detected, a message will be
displayed.
If there are no errors then the .OBJ output file may be loaded into
memory by typing the command:
APX>LOAD file name
When the loader is finished, it will display:
PRESS "RETURN" TO EXECUTE
(OR CTRL-P TO SAVE)
If your program has set up the start vector at location $400, you can
press RETURN to start it. You may however, prefer to press RESET and
use the monitor to run or test your program. Programs that set up the
required Apex system parameters, USRMEM ($432) and PROSIZ ($436), may
be made into .SAV files by first pressing CTRL-P and then entering:
APX>SAVE file name
If you do want a listing, you will need to change the defaults as
follows:
At the message: CHANGE DEFAULTS (N/Y)?, enter: Y
At the message: DEVICE NUMBERS (OBJECT, LISTING)?, enter: 3,2
At the message: DO CROSS REFERENCE (N/Y)?, enter: Y
At the message: CHANGE DEFAULTS (N/Y)?, enter: N
RESERVED NAMES
These names have special meaning to the assembler and cannot be used as
label names:
D0 - D7 Data registers
A0 - A7 Address registers
SP Stack pointer (same as A7)
CCR Condition code register
SR Status register
USP User stack pointer
SSP Supervisor stack pointer
PC Program counter
EFFECTIVE ADDRESS MODES
The addressing modes are:
Dn Data register direct
An Address register direct
(An) Address register indirect
(An)+ Address register indirect with postincrement
-(An) Address register indirect with predecrement
d(An) Address register indirect with displacement
d(An,Xn) Address register indirect with index
Abs.W Absolute short (word)
Abs.L Absolute long
d(PC) Program counter with displacement
d(PC,Xn) Program counter with index
#<xxx> Immediate (size depends on opcode size)
The displacement (d) is +/-32767, except when used with indexing, where
it is +/-127. The index register (Xn) can be any register (D0-D7 or
A0-A7). The size of the index register can be specified by either ".W"
or ".L". The assembler consistently defaults to the word size (.W)
everywhere that a size can be specified.
CHARACTER SUMMARY
The assembler uses the following characters. (Expression operations are
performed on all 32 bits unless indicated otherwise.)
+ Addition and unary plus
- Subtraction and unary minus
* Multiplication (16 * 16 = 32 bits)
/ Division (32 / 16 = 16 bits)
\ Remainder (32 \ 16 = 16 bits)
& Logical "and" operation
! Logical "or" operation
~ Logical "not" operation
$ Hex value
@ Current program counter (PC) value
' " ASCII character value or string
; Comment delimiter
# Immediate address mode
() Enclose indirect or index registers
[] Enclose subexpressions
= Equal
# Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
. Size specifier: .B .W .L .S
, Parameter separator
A-Z Characters that can be used in a name
a-z
_ (Underline)
0-9
: Label definition (optional)
^ (Not used)
? (Not used)
MOTOROLA STANDARD
An attempt has been made to be compatible with the assembly-language
standard defined by Motorola. However, ASM.XPL has features not defined
by Motorola, and Motorola has features that are incompatible with the
design of ASM.XPL. This section describes the differences.
In ASM.XPL all comments must be preceded by a semicolon (;). An asterisk
(*) cannot be used because of the way expressions are parsed. (Motorola
does not allow space characters inside expressions.)
In ASM.XPL an at-sign (@) is used to represent the current program
counter (PC) value. (An asterisk would have worked, but it was too con-
fusing in expressions such as: "**2" or "N3/*+2".) An at-sign cannot be
used to represent octal numbers, and there is no octal representation.
In ASM.XPL labels must always start in the first column. Also the case
of a letter is ignored; for example, the following names are the same:
frog, FROG, FrOg.
ASM.XPL does not implement the shift operators, "<<" and ">>". (In
almost all cases these may be replaced by multiplication and division
by powers of 2.)
The following Motorola pseudo-ops are not implemented:
SECTION LLEN
RORG PLEN
OFFSET TTL
EQUR NOOBJ
REG FAIL
SET FORMAT
NOL NOFORMAT
SPC MASK2
NOPAGE IDNT
Currently ASM.XPL has no macro capability. Also there is no linker; the
.OBJ files are loaded directly.
ASM.XPL assumes that the printer handler formats the page, thus the
page-formatting pseudo-ops such as LLEN and PLEN are incompatable.
ASM.XPL implements conditional-assembly pseudo-ops in a completely
different way than Motorola does. Also ASCII strings are completely
different.
ASM.XPL has no special "local" labels.
In ASM.XPL branches always default to ".L" unless ".S" is specified,
even when references are within range of the ".S" specification.
In ASM.XPL there is no optimization of opcodes such as converting
"ADD #3,D5" to "ADDQ #3,D5".
In ASM.XPL all address modes must be explicitly stated. Thus, there is
no implied relative addressing. For example, "MOVE #3,FROG" is not
automatically converted to "MOVE #3,FROG-@(PC)".
In ASM.XPL syntax is strictly checked. For example, "MOVE #3,A0" is
flagged because it should be "MOVEA #3,A0". (MOVE and MOVEA perform
significantly different operations which should not be confused.)
ASM.XPL always defaults to the word size, ".W", consistent with the
Motorola standard. Beware of assemblers that don't. A program that
works with one assembler may not work when it is assembled by another.
dard. Beware of assemblers that don't. A program that
works with one assembler may not work when it is asse